package cn.laixueit.controller;

import cn.laixueit.mapper.BanjiMapper;
import cn.laixueit.mapper.StudentMapper;
import cn.laixueit.mapper.TeacherMapper;
import cn.laixueit.service.PhotoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/index")
public class IndexController {

    @Autowired
    private StudentMapper studentMapper;
    @Autowired
    private TeacherMapper teacherMapper;
    @Autowired
    private BanjiMapper banjiMapper;

    @GetMapping("/totalPerson")
    public @ResponseBody   Map<String,Long> totalPerson(){
        HashMap<String, Long> map = new HashMap<>();

        Long studentCount = studentMapper.countByExample(null);
        Long teacherCount = teacherMapper.countByExample(null);


        Long banjiCount = banjiMapper.countByExample(null);

        map.put("studentCount",studentCount);
        map.put("teacherCount",teacherCount);
        map.put("banjiCount",banjiCount);
        map.put("totalCount",studentCount+teacherCount);

        return map;
    }

   /* @GetMapping("/totalStudent")
    public @ResponseBody Integer totalStudent(){

        Long studentCount = studentMapper.countByExample(null);

        return studentCount.intValue();
    }*/


    @Autowired
    private PhotoService photoService;

    @GetMapping("/list")
    public @ResponseBody List<String> list(){
         return  photoService.list();
    }
}
